package Java学习;

import javax.swing.*;
import java.awt.*;

class learn extends JFrame{
    public learn(){
        frame();
        area();
        this.setVisible(true);
    }
    public void area(){
        JScrollPane pane = new JScrollPane();
        pane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
        pane.setBounds(20,20,300,100);
        JLabel label = new JLabel("你好我是小颗粒");
        pane.setBackground(Color.YELLOW);
        label.setBounds(20,20,200,30);
        this.add(label);
        this.add(pane);
    }
    public void frame(){
        this.setTitle("面板");
        this.setSize(500,550);
        this.setLocationRelativeTo(null);//居中
        this.setAlwaysOnTop(true);//最上方
        this.setDefaultCloseOperation(3);
        this.setLayout(null);
    }
}
public class Jpanel {
    public static void main(String[] args) {
        learn learn = new learn();
    }
}
